package serviceset1

import org.springframework.beans.factory.annotation.Autowired
import serviceset1.feign.ServiceSet2

class SampleApi1Controller {
    static responseFormats = ['json', 'xml']

    def serviceSet2ProxyService

    @Autowired
    ServiceSet2 serviceSet2

    def index(String dependency) {
        def result = [provider: "sampleApi1@serviceSet1", dependency: dependency]

        switch (dependency) {
            case "restTemplate":
                result.consumption = serviceSet2ProxyService.sampleApi2(dependency)
                break
            case "feign":
                result.consumption = serviceSet2.sampleApi2(dependency)
                break
            default:
                result.consumption = serviceSet2ProxyService.sampleApi2(dependency)
                break
        }

        respond result, formats: responseFormats
    }
}
